﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeus.Thunder.Core;

namespace SharpTrainer.Linq
{
    class DirList : ITestCase
    {
        public void Run()
        {
            DirectoryInfo[] dirs = new DirectoryInfo(@"e:\\").GetDirectories();
            var query =
                from d in dirs
                where (d.Attributes & FileAttributes.System) == 0
                select new
                {
                    DirectoryName = d.FullName,
                    Created = d.CreationTime,
                    Files = from f in d.GetFiles()
                            where (f.Attributes & FileAttributes.Hidden) == 0
                            select new { FileName = f.Name, f.Length, }
                };

            foreach (var dirFiles in query)
            {
                Console.WriteLine("Directory: " + dirFiles.DirectoryName);
                foreach (var file in dirFiles.Files)
                    Console.WriteLine(" " + file.FileName + " Len: " + file.Length);
            }
        }
    }
}
